﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Directory.Model;

namespace Directory.BLL
{
	public class MessageBoard
	{
		private static Directory.IDAL.IMessgeBoard dal = new Directory.DAL.MessageBoard();

		public MessageInfo CreateMessage(string title, string author, string content, string authorIp, bool isChecked, int topState)
		{
			if (BLLHelper.ValidateNotEmptyStringParameter(ref title))
			{
				return dal.CreateMessage(title, author, content, authorIp, DateTime.Now, isChecked, topState);
			}
			else
			{
				throw new ArgumentException("Invalid title parameter.");
				//return null;
			}
		}

		public IList<MessageInfo> GetMessageList(bool isChecked, int pageIndex, int pageSize, out int totalRecords)
		{
			return dal.GetMessageList(isChecked, pageIndex, pageSize, out totalRecords);
		}

		public MessageInfo GetMessageInfo(int msgId)
		{
			return dal.GetMessage(msgId);
		}

		public void ReplyMessage(int MessageId, string checker, string reply, bool isChecked, int topState)
		{
			dal.ReplyMessage(MessageId, checker, reply,DateTime.Now, isChecked, topState);
		}

		public void DeleteMessage(int msgID)
		{
			dal.DeleteMessage(msgID);
		}
	}
}
